package com.yundingai.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yundingai.domain.entity.UserSocialData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
/**
 * @Author HuangZhengmin
 * @desc
 * @Date 2025/7/22 14:51
 * @Version 1.0
 */
@Mapper
public interface UserSocialDataMapper extends BaseMapper<UserSocialData> {

  /**
   * 根据contactsHashed查询用户id
   * @param contactsHashed
   * @return
   */
  @Select("SELECT user_id FROM user_social_data WHERE contacts_hashed = #{contactsHashed}")
  List<Integer> findUserIdsByContactsHashed(@Param("contactsHashed") String contactsHashed);

  /**
   * 根据用户id更新用户社交数据
   * @param userSocialData
   */

  void updateByUserId(UserSocialData userSocialData);

  void removeByUserId(@Param("userId") Integer userId);

  /**
   * 根据用户id查询用户社交数据
   * @param userId
   * @return UserSocialData
   */
  @Select("SELECT * FROM user_social_data WHERE user_id = #{userId}")
  UserSocialData selectByUserId(@Param("userId") Integer userId);

  @Select("SELECT * FROM user_social_data WHERE user_id = #{userId}")
  UserSocialData queryByUserId(@Param("userId") Integer userId);
}
